package easy;

public class Solution_1848 {

    public int getMinDistance(int[] nums, int target, int start) {
        for (int i = start, j = start; i >= 0 || j < nums.length; i--, j++) {
            if (i >= 0) {
                if (target == nums[i]) {
                    return start - i;
                }
            }
            if (j < nums.length) {
                if (target == nums[j]) {
                    return j - start;
                }
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        Solution_1848 model = new Solution_1848();
        System.out.println(model.getMinDistance(new int[]{1, 2, 3, 4, 5}, 5, 3));
    }
}
